package cn.itcast.service.impl;

import cn.itcast.service.WorkspaceService;
import cn.itheima.feign.DishClient;
import cn.itheima.feign.OrderClient;
import cn.itheima.feign.SetmealClient;
import cn.itheima.goods.vo.DishOverViewVO;
import cn.itheima.goods.vo.SetmealOverViewVO;
import cn.itheima.orders.vo.OrderOverViewVO;
import cn.itheima.sys.vo.BusinessDataVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

@Service
@Slf4j
@AllArgsConstructor
public class WorkspaceServiceImpl implements WorkspaceService {

    private OrderClient orderClient;
    private SetmealClient setmealClient;
    private DishClient dishClient;


    /**
     * 查询今日运营数据
     *
     * @return 营业额数据
     */
    @Override
    public BusinessDataVO getBusinessData() {
        LocalDateTime start = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
        LocalDateTime end = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);

        return orderClient.getBusinessData(start, end);
    }

    /**
     * 查询订单管理数据
     *
     * @return 订单数据
     */
    @Override
    public OrderOverViewVO getOverviewOrders() {
        LocalDateTime start = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
        LocalDateTime end = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
        return orderClient.getAllCountByStatus(start, end);
    }

    /**
     * 查询套餐总览
     *
     * @return 套餐数据
     */
    @Override
    public SetmealOverViewVO getOverviewSetmeals() {
        return setmealClient.getCountByStatus();
    }

    /**
     * 查询菜品总览
     *
     * @return 菜品数据
     */
    @Override
    public DishOverViewVO getOverviewDishes() {
        return dishClient.getCountByStatus();
    }
}
